<div class="page-top clearfix" baScrollPosition maxHeight="50" (scrollChange)="scrolledChanged($event)"
     [ngClass]="{scrolled: isScrolled}">
  <a routerLink="/pages/dashboard" class="al-logo clearfix"><span>ng</span>testing</a>

  <div class="menu change-orgs">
    <div ngbDropdown class="btn-group">
      <button class="btn btn-default" ngbDropdownToggle>
        <span class="fa fa-bars"></span>
        <span class="text">组织</span>
      </button>
      <div class="dropdown-menu">
        <ng-container *ngIf="orgs && orgs.length > 0">
          <button (click)="selectOrg(item)" *ngFor="let item of orgs" class="dropdown-item">
            <span class="link">
              <span [class.transparent]="item?.id!=orgId" class="fa fa-check"></span>
              &nbsp;{{item.name}}
            </span>
          </button>
        </ng-container>

        <button *ngIf="!orgs || orgs.length == 0" class="dropdown-item">
          无
        </button>

      </div>
    </div>
  </div>

  <div class="menu">
    <div *ngIf="projects?.length > 0" ngbDropdown class="btn-group">
      <button class="btn btn-default dropdown" ngbDropdownToggle>项目</button>
      <div class="dropdown-menu">
        <button class="dropdown-item">当前项目</button>
        <button class="dropdown-item">
          <ng-container *ngFor="let item of projects; let i = index">
            <a *ngIf="item.prjId == prjId" (click)="selectProject(item.prjId)" class="link">
              {{item.prjName}}
            </a>
          </ng-container>
          <a *ngIf="!projects || projects.length == 0">无</a>
        </button>

        <button class="dropdown-item next">最近查看</button>
        <ng-container *ngFor="let item of projects; let i = index">
          <button *ngIf="item.prjId != prjId" class="dropdown-item" class="dropdown-item">
            <a (click)="selectProject(item.prjId)" class="link">
              {{item.prjName}}</a>
          </button>
        </ng-container>

        <button *ngIf="!projects || projects.length < 2" class="dropdown-item" style="margin: 0 5px;">
          无
        </button>

        <li class="dropdown-divider"></li>

        <button class="dropdown-item">
          <a [routerLink]="['/pages/org/' + orgId + '/prjs']">所有项目</a>
        </button>

      </div>
    </div>

<!--    <div *ngIf="prjId" ngbDropdown class="btn-group">
      <button (click)="gotoModule('design')" class="btn btn-default">策略模型</button>
    </div>-->
    <div *ngIf="prjId" ngbDropdown class="btn-group">
      <button (click)="gotoModule('design')" class="btn btn-default">用例</button>
    </div>

    <div *ngIf="prjId" ngbDropdown class="btn-group">
      <button (click)="gotoModule('suite')" class="btn btn-default">测试集</button>
    </div>

    <div *ngIf="prjId" ngbDropdown class="btn-group">
      <button (click)="gotoModule('implement')" class="btn btn-default">执行</button>
    </div>

    <div ngbDropdown class="btn-group">
      <button class="btn btn-default dropdown" ngbDropdownToggle>问题</button>

      <div class="dropdown-menu">
        <button class="dropdown-item">
          <a [routerLink]="['/pages/org/' + orgId + '/prj/' + prjId + '/issue/create']">新建问题</a>
        </button>

        <li class="dropdown-divider"></li>

        <button (click)="gotoModule('issue', 'lastest')" class="dropdown-item">
          <span class="link">当前查询</span>
        </button>
        <button (click)="gotoModule('issue')" class="dropdown-item">
          <span class="link">重新查询</span>
        </button>

        <li class="dropdown-divider"></li>

        <button class="dropdown-item next">最近查询</button>
        <ng-container *ngFor="let item of queries; let i = index">
            <button class="dropdown-item" class="dropdown-item">
              <a (click)="selectQuery(item.id)" class="link">
                {{item.name}}</a>
            </button>
        </ng-container>
        <button *ngIf="!queries || queries.length < 1" class="dropdown-item" style="margin: 0 5px;">
          无
        </button>

        <li class="dropdown-divider"></li>

        <button class="dropdown-item">
          <a [routerLink]="['/pages/org/' + orgId + '/prj/' + prjId + '/issue-query/list']">管理查询</a>
        </button>

      </div>
    </div>

    <!-- <div *ngIf="prjId && !environment.production" ngbDropdown class="btn-group">
     <button (click)="gotoModule('autotest')" class="btn btn-default">自动化</button>
   </div>
    -->

    <div ngbDropdown class="btn-group">
      <button [routerLink]="['/pages/org-admin/org-settings/org/list']" class="btn btn-default">
        管理
      </button>
    </div>
<!--    <div *ngIf="profile?.sysPrivilege?.sys_admin" ngbDropdown class="btn-group">
      <button [routerLink]="['/pages/sys-admin']" class="btn btn-default">
        系统
      </button>
    </div>-->

  </div>

  <div class="search">
    <i class="fa fa-search" ng-click="startSearch()"></i>
    <input [(ngModel)]="keywords" (ngModelChange)=onSearchKeywordChanged($event) id="searchInput" type="text" placeholder="输入用例编号">
  </div>

  <div class="user-profile clearfix">
    <div class="dropdown al-user-profile">
      <a class="profile-toggle-link dropdown-toggle" id="user-profile-dd" data-toggle="dropdown" aria-expanded="false">
        <img src="{{ profile?.avatar | imgPath }}">
      </a>
      <ul class="dropdown-menu top-dropdown-menu profile-dropdown" aria-labelledby="user-profile-dd">
        <li class="dropdown-item">
          <a [routerLink]="['/pages/personal/profile']" href>
            <i class="fa fa-user"></i>个人信息
          </a>
        </li>
<!--        <li class="dropdown-item">
          <a [routerLink]="['/pages/personal/settings']" href>
            <i class="fa fa-cog"></i>设置
          </a>
        </li>-->
        <li (click)="logout()" class="dropdown-item"><a href="javascript:void(0);" class="signout"><i class="fa fa-power-off"></i>登出</a></li>
      </ul>
    </div>
    <ba-msg-center [alerts]="alerts" [msgs]="msgs"></ba-msg-center>
  </div>
</div>
